/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: GaoBo
 * Date: 2021-04-23
 * Time: 19:45
 */
class Calculator {
    private int num1;
    private int num2;

    public Calculator() {

    }

    public Calculator(int num1,int num2) {
        this.num1 = num1;
        this.num2 = num2;
    }

    public int getNum1() {
        return num1;
    }

    public void setNum1(int num1) {
        this.num1 = num1;
    }

    public int getNum2() {
        return num2;
    }

    public void setNum2(int num2) {
        this.num2 = num2;
    }

    public int add() {
        return this.num1+this.num2;
    }

    public int sub() {
        return this.num1-this.num2;
    }

    public int mul() {
        return this.num2*this.num1;
    }

    public double dev() {
        return this.num1*1.0/this.num2;
    }

}

class MyValue {
    public int val;
}

public class TestDemo2 {

    public static void main(String[] args) {
        MyValue myValue1 = new MyValue();
        MyValue myVal1 = myValue1;
    }

    //按值传递-》
    public static void swap(MyValue myVal1,MyValue myVal2) {
        int tmp = myVal1.val;
        myVal1.val = myVal2.val;
        myVal2.val = tmp;
    }
    public static void main4(String[] args) {
        MyValue myValue1 = new MyValue();
        myValue1.val = 10;
        MyValue myValue2 = new MyValue();
        myValue2.val = 20;
        System.out.println(myValue1.val );
        System.out.println(myValue2.val );
        swap(myValue1,myValue2);
        System.out.println(myValue1.val );
        System.out.println(myValue2.val );
    }

    //类的调用者 自己
    public static void main2(String[] args) {
        Calculator calculator = new Calculator(40,60);
        System.out.println(calculator.add());
        System.out.println(calculator.sub());
        System.out.println(calculator.mul());
        System.out.println(calculator.dev());
    }

    public static void main1(String[] args) {
        Calculator calculator = new Calculator();
        calculator.setNum1(10);
        calculator.setNum2(20);

        System.out.println(calculator.add());
        System.out.println(calculator.sub());
        System.out.println(calculator.mul());
        System.out.println(calculator.dev());
    }
}
